using Indiefreaks.AceOnSteroids.Entities;
using Indiefreaks.AceOnSteroids.Logic.Behaviors;
using Indiefreaks.Xna.Core;
using Indiefreaks.Xna.Logic;

namespace Indiefreaks.AceOnSteroids.Logic
{
    /// <summary>
    /// The Player class will handle all player related behaviors
    /// </summary>
    /// <remarks>
    /// We could place all the code that will be stored in this class at the GameState level using a PlayerAgent directly but creating such a class 
    /// will help us later when the project will get bigger.
    /// 
    /// The Player class inherits from the PlayerAgent class which allows us to provide Commands and control behaviors.
    /// </remarks>
    public class Player : PlayerAgent
    {
        private readonly PlayerSpaceShip _spaceShip;

        /// <summary>
        /// Creates a new instance
        /// </summary>
        public Player()
        {
            // we create our player spaceship entity and ask the GameState to Preload its content
            _spaceShip = new PlayerSpaceShip();
            Application.GameState.PreLoad(_spaceShip);

            // we add the current Player (PlayerAgent which inherits from SunBurn's BaseComponent) to the spaceship SceneObject.
            _spaceShip.Components.Add(this);

            // we now can add our custom behavior to the Player instance so that the attached SpaceShip gets its World modified from it
            Add(new PlayerInputBehavior());
            // we add our behavior to change this spaceship position when it reaches one of the screen sides
            Add(new WrappedScreenBehavior());
            // we finally add our plane constraint behavior so that the spaceship keeps on the 0f Y plane
            Add(new PlaneConstraintBehavior());
        }

        /// <summary>
        /// Returns the current Player SpaceShip instance
        /// </summary>
        public PlayerSpaceShip SpaceShip { get { return _spaceShip; } }
    }
}